package com.zjcloud.motr.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zjcloud.common.annotation.Log;
import com.zjcloud.common.core.controller.BaseController;
import com.zjcloud.common.core.domain.AjaxResult;
import com.zjcloud.common.enums.BusinessType;
import com.zjcloud.motr.domain.ZjyTimingType;
import com.zjcloud.motr.service.IZjyTimingTypeService;
import com.zjcloud.common.utils.poi.ExcelUtil;
import com.zjcloud.common.core.page.TableDataInfo;

/**
 * 计时类型维护Controller
 *
 * @author wxl
 * @date 2024-09-24
 */
@RestController
@RequestMapping("/motr/timingtype")
public class ZjyTimingTypeController extends BaseController
{
    @Autowired
    private IZjyTimingTypeService zjyTimingTypeService;

    /**
     * 查询计时类型维护列表
     */
    @PreAuthorize("@ss.hasPermi('motr:timingtype:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZjyTimingType zjyTimingType)
    {
        startPage();
        List<ZjyTimingType> list = zjyTimingTypeService.selectZjyTimingTypeList(zjyTimingType);
        return getDataTable(list);
    }

    /**
     * 导出计时类型维护列表
     */
    @PreAuthorize("@ss.hasPermi('motr:timingtype:export')")
    @Log(title = "计时类型维护", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZjyTimingType zjyTimingType)
    {
        List<ZjyTimingType> list = zjyTimingTypeService.selectZjyTimingTypeList(zjyTimingType);
        ExcelUtil<ZjyTimingType> util = new ExcelUtil<ZjyTimingType>(ZjyTimingType.class);
        util.exportExcel(response, list, "计时类型维护数据");
    }

    /**
     * 获取计时类型维护详细信息
     */
    @PreAuthorize("@ss.hasPermi('motr:timingtype:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zjyTimingTypeService.selectZjyTimingTypeById(id));
    }

    /**
     * 新增计时类型维护
     */
    @PreAuthorize("@ss.hasPermi('motr:timingtype:add')")
    @Log(title = "计时类型维护", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZjyTimingType zjyTimingType)
    {
        return toAjax(zjyTimingTypeService.insertZjyTimingType(zjyTimingType));
    }

    /**
     * 修改计时类型维护
     */
    @PreAuthorize("@ss.hasPermi('motr:timingtype:edit')")
    @Log(title = "计时类型维护", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZjyTimingType zjyTimingType)
    {
        return toAjax(zjyTimingTypeService.updateZjyTimingType(zjyTimingType));
    }

    /**
     * 删除计时类型维护
     */
    @PreAuthorize("@ss.hasPermi('motr:timingtype:remove')")
    @Log(title = "计时类型维护", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zjyTimingTypeService.deleteZjyTimingTypeByIds(ids));
    }
}
